<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>[|.siteName|]</title>
    [|if .zTree|]
    <link rel="stylesheet" href="/static/zTree3/css/demo.css?t=5" type="text/css">
    <link rel="stylesheet" href="/static/zTree3/css/zTreeStyle/zTreeStyle.css" type="text/css"> [|end|]
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/main.css">
    <script src="/static/layui/layui.js?s=36"></script>
    <script src="/static/js/main.js?s=2124"></script>
</head>


<form>
    <div class="layui-input-inline">

        <label class="layui-form-label">登录名:</label>
        <div class="layui-input-inline">
            <input type="text" name="userName" id="userName" lay-verify="required|number" autocomplete="off" class="layui-input" value="">
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">日志内容:</label>
            <div class="layui-input-inline">
                <input type="text" name="logContent" id="logContent" lay-verify="required|number" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">时间范围:</label>
            <div class="layui-input-inline" style="width:180px;">
                <input type="text" name="date1" id="date1" lay-verify="date" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input" value="">

            </div>
            <label>-</label>
            <div class="layui-input-inline" style="width:180px;">
                <input type="text" name="date2" id="date2" lay-verify="date" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="queryBtn">开始查询</button>
        </div>

    </div>

</form>
<div class="layui-form">
    <table class="layui-table" lay-data="{width: 'full-10', height: 'full-105', url:'', page:true, id:'idTest'}" id="dataTable">
        <thead>
            <tr>
                <th lay-data="{field:'userid', width:200, fixed: true}">推广号</th>
                <th lay-data="{field:'nickname', width:200}">昵称</th>
                <th lay-data="{field:'admin', width:200}">管理员</th>
                <th lay-data="{field:'time', width:200}">时间</th>
                <th lay-data="{field:'amount', width:200}">金币数</th>
                <th lay-data="{field:'explain', width:20000}">说明</th>
            </tr>
        </thead>
          
    </table>
</div>


<script>
    layui.use(['table', 'form', 'layedit', 'laydate', 'jquery', 'element'], function() {
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;
        $ = layui.jquery
        var element = layui.element;
        var table = layui.table;
        //var table = layui.table;

        //日期
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#date2'
        });



        //填写默认时间
        Date.prototype.Format = function(fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份 
                "d+": this.getDate(), //日 
                "h+": this.getHours(), //小时 
                "m+": this.getMinutes(), //分 
                "s+": this.getSeconds(), //秒 
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                "S": this.getMilliseconds() //毫秒 
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }

        var date = new Date();
        var today = Date.parse(new Date()) / 1000;
        var time1 = today -24*3600*30; //获取当前秒数()
        var time2 = today;

        var unixTimestamp = new Date(time1 * 1000).Format("yyyy-MM-dd");

        document.getElementById('date1').value = unixTimestamp 

        var unixTimestamp = new Date(time2 * 1000).Format("yyyy-MM-dd");

        document.getElementById('date2').value = unixTimestamp 




        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            date1: function(value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            },
            pass: [/(.+){6,12}$/, '密码必须6到12位'],
            content: function(value) {
                layedit.sync(editIndex);
            },
            user: function(value) {
                if (value.length < 5) {
                    return "请选择用户"
                }
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });


        $('#selectType').change(function() {
            var opt = $("#selectType").val();
            //alert(opt)
            //$("#queryBtn").trigger("submit");
            btnClick(table);
        });

        //监听提交
        form.on('submit(queryBtn)', function(data) {
            btnClick(table);
            return false;
        });

        btnClick(table);
    });

    var GetText =  function(result)
    {
        if(result == 0)
        {
            return "成功"
        }else
        {
            return "失败"
        }

    }
    function btnClick(table) {
        //var amountTitle = $("#selectType").find("option:selected").text(); //获取Select选择的Text
        var date1 = document.getElementById('date1').value;
        var date2 = document.getElementById('date2').value;
        if (!CheckTimeRange(date1 + " 00:00:00" ,date2 + " 00:00:00" ,365))
        {
            return false;
        }
        var userName = document.getElementById("userName")
        var logContent = document.getElementById("logContent")
        var date1 = document.getElementById("date1")
        var date2 = document.getElementById("date2")

       
        table.render({
            elem: '#dataTable',
            data: "",
            url: '/sysmangerlogs/table/',
            where: {
                userName: userName.value,
                logContent: logContent.value,
                date1: date1.value,
                date2: date2.value
            },
            cols: [
                [ //标题栏
                    {
                        field: 'userName',
                        title: '登录名',
                        height: 300,
                        width: 200
                    }, {
                        field: 'operationTime',
                        title: '操作时间',
                        height: 300,
                        width: 200
                    }, {
                        field: 'operationIP',
                        title: '操作IP',
                        height: 300,
                        width: 200
                    }, {
                        field: 'operationResult',
                        title: '操作结果',
                        height: 300,
                        width: 200,
                        templet: '<div>{{ GetText(d.operationResult) }} </div>',
                    }, {
                        field: 'content',
                        title: '操作内容',
                        height: 300,
                        width: 10000
                    }
                ]
            ],
            skin: 'row', //表格风格
            even: true,
            page: true,
            limits: [10, 20, 30, 40, 50, 100],
            limit: 50, //每页默认显示的数量
            width: 'full-10',
            rules: 'all',
            height: 'full-105'
        });
    }
</script>
</body>

</html>